/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.service;


import info.peigen.hotpot.business.customer.facade.CustomerServiceFacade;
import info.peigen.hotpot.business.customer.facade.order.authentication.CustomerApplyAuthenticationOrder;
import info.peigen.hotpot.business.customer.facade.order.authentication.CustomerApplyPersonalAuthenticationOrder;
import info.peigen.hotpot.business.customer.facade.order.authentication.CustomerAuditAuthenticationOrder;
import info.peigen.hotpot.business.customer.facade.order.check.CustomerDuplicateCheckOrder;
import info.peigen.hotpot.business.customer.facade.order.check.CustomerPayPasswordCheckOrder;
import info.peigen.hotpot.business.customer.facade.order.login.CustomerLoginOrder;
import info.peigen.hotpot.business.customer.facade.order.login.CustomerLogoutOrder;
import info.peigen.hotpot.business.customer.facade.order.register.CustomerForgotPasswordOrder;
import info.peigen.hotpot.business.customer.facade.order.register.CustomerRegisterOrder;
import info.peigen.hotpot.business.customer.facade.order.update.CustomerUpdateOrder;
import info.peigen.hotpot.business.customer.facade.result.CustomerForgotPasswordResult;
import info.peigen.hotpot.business.customer.facade.result.authentication.CustomerApplyAuthenticationResult;
import info.peigen.hotpot.business.customer.facade.result.authentication.CustomerApplyPersonalAuthenticationResult;
import info.peigen.hotpot.business.customer.facade.result.authentication.CustomerAuditAuthenticationResult;
import info.peigen.hotpot.business.customer.facade.result.check.CustomerDuplicateCheckResult;
import info.peigen.hotpot.business.customer.facade.result.check.CustomerPayPasswordCheckResult;
import info.peigen.hotpot.business.customer.facade.result.login.CustomerLoginResult;
import info.peigen.hotpot.business.customer.facade.result.operator.CustomerOperatorLogoutResult;
import info.peigen.hotpot.business.customer.facade.result.register.CustomerRegisterResult;
import info.peigen.hotpot.business.customer.facade.result.register.CustomerUpdateResult;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceInvoke;
import org.noear.solon.annotation.Component;

/**
 * <b>(CustomerService)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/7/29
 */
@SuppressWarnings({"rawtypes", "unused"})
@Component
public class CustomerService extends AbstractCustomerService implements CustomerServiceFacade {

    @Override
    public CustomerRegisterResult register(CustomerRegisterOrder order) {
        ProcessorServiceContext serviceContext = ProcessorServiceContext.builder().order(order).result(new CustomerRegisterResult()).build();
        execute(serviceContext, new ProcessorServiceInvoke() {
            @Override
            public void addPreProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerRegisterCheckProcessor);
            }

            @Override
            public void addProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerRegisterProcessor, customerActivePartnerProcessor, customerCreateAccountProcessor);
            }

            @Override
            public void addPostProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(storeCustomerProcessor, customerRegisterResultProcessor);
            }
        });
        return (CustomerRegisterResult) serviceContext.getResult();
    }

    @Override
    public CustomerLoginResult login(CustomerLoginOrder order) {
        ProcessorServiceContext serviceContext = ProcessorServiceContext.builder().order(order).result(new CustomerLoginResult()).build();
        execute(serviceContext, new ProcessorServiceInvoke() {
            @Override
            public void addPreProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerLoginCheckProcessor, customerActiveProcessor, customerActivePartnerProcessor);
            }

            @Override
            public void addProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerLoginProcessor);
            }

            @Override
            public void addPostProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(storeCustomerProcessor, customerLoginResultProcessor);
            }
        });
        return (CustomerLoginResult) serviceContext.getResult();
    }

    @Override
    public CustomerOperatorLogoutResult logout(CustomerLogoutOrder order) {
        return null;
    }

    @Override
    public CustomerPayPasswordCheckResult checkPayPassword(CustomerPayPasswordCheckOrder order) {
        return null;
    }

    @Override
    public CustomerUpdateResult updateMobile(CustomerUpdateOrder order) {
        ProcessorServiceContext serviceContext = ProcessorServiceContext.builder().order(order).result(new CustomerUpdateResult()).build();
        execute(serviceContext, new ProcessorServiceInvoke() {
            @Override
            public void addPreProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerUpdateCheckProcessor, customerActiveProcessor);
            }

            @Override
            public void addProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerUpdateMobileProcessor);
            }

            @Override
            public void addPostProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(storeCustomerProcessor, customerUpdateResultProcessor);
            }
        });
        return (CustomerUpdateResult) serviceContext.getResult();
    }

    @Override
    public CustomerUpdateResult updateAvatarAndNickname(CustomerUpdateOrder order) {
        ProcessorServiceContext serviceContext = ProcessorServiceContext.builder().order(order).result(new CustomerUpdateResult()).build();
        execute(serviceContext, new ProcessorServiceInvoke() {
            @Override
            public void addPreProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerUpdateCheckProcessor, customerActiveProcessor);
            }

            @Override
            public void addProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(customerUpdateNicknameProcessor, customerUpdateAvatarProcessor);
            }

            @Override
            public void addPostProcessor(ProcessorServiceContext serviceContext) {
                serviceContext.addProcessors(storeCustomerProcessor, customerUpdateResultProcessor);
            }
        });
        return (CustomerUpdateResult) serviceContext.getResult();
    }

    @Override
    public CustomerUpdateResult updateVerify(CustomerUpdateOrder order) {
        return null;
    }

    @Override
    public CustomerUpdateResult updateEmail(CustomerUpdateOrder order) {
        return null;
    }

    @Override
    public CustomerUpdateResult forgotPayPassword(CustomerUpdateOrder order) {
        return null;
    }

    @Override
    public CustomerUpdateResult forgotLoginPassword(CustomerUpdateOrder order) {
        return null;
    }

    @Override
    public CustomerUpdateResult updatePayPassword(CustomerUpdateOrder order) {
        return null;
    }

    @Override
    public CustomerUpdateResult updateLoginPassword(CustomerUpdateOrder order) {
        return null;
    }

    @Override
    public CustomerForgotPasswordResult forgotPassword(CustomerForgotPasswordOrder customerForgotPasswordOrder) {
        return null;
    }

    @Override
    public CustomerDuplicateCheckResult duplicateCheck(CustomerDuplicateCheckOrder order) {
        return null;
    }

    @Override
    public CustomerApplyAuthenticationResult applyAuthentication(CustomerApplyAuthenticationOrder order) {
        return null;
    }

    @Override
    public CustomerApplyPersonalAuthenticationResult applyPersonalAuthentication(CustomerApplyPersonalAuthenticationOrder order) {
        return null;
    }

    @Override
    public CustomerAuditAuthenticationResult auditAuthentication(CustomerAuditAuthenticationOrder order) {
        return null;
    }
}
